setTimeout(() => {
  console.log('first setTimeout eval');
  new Promise((resolve) => {
    console.log('promise constructor eval begin');
    resolve(12);
    console.log('promise constructor eval end');
  }).then((data) => {
    console.log("promise'then in setTimeout", data);
  }).catch((reason) => {
    console.log('reason of unhandle err', reason);
  });
  process.nextTick(() => {
    console.log('nextTick in setTimeout');
  });
});

setImmediate(() => {
  console.log('first setImmediate eval');
  new Promise((resolve) => {
    console.log('promise constructor eval begin');
    console.log('promise1');
    for (let i = 0; i < 1000; i++) {
      (i === 99) && resolve(12);
    }
    console.log('promise constructor eval end');
  }).then((data) => {
    console.log("promise'then in setImmediate", data);
  }).catch((reason) => {
    console.log('reason of unhandle err', reason);
  });
  process.nextTick(() => {
    console.log('nextTick in setImmediate');
  });
});

new Promise((resolve) => {
  console.log('independent promise');
  resolve('second##########################pomise then data');
}).then(() => {
  console.log('then of the independent promise');
}).catch((reason) => {
  console.log('reason of unhandle err', reason);
});

process.nextTick(() => {
  console.log('independent nextTick');
});

setTimeout(() => {
  console.log('second#####################first setTimeout eval');
  new Promise((resolve) => {
    console.log('second#####################promise constructor eval begin');
    resolve(12);
    console.log('second#####################promise constructor eval end');
  }).then((data) => {
    console.log("second#####################promise'then in setTimeout", data);
  }).catch((reason) => {
    console.log('second#####################reason of unhandle err', reason);
  });
  process.nextTick(() => {
    console.log('second#####################nextTick in setTimeout');
  });
});

setImmediate(() => {
  console.log('second#####################first setImmediate eval');
  new Promise((resolve) => {
    console.log('second#####################promise constructor eval begin');
    resolve(12);
    console.log('second#####################promise constructor eval end');
  }).then((data) => {
    console.log("second#####################promise'then in setImmediate", data);
  }).catch((reason) => {
    console.log('second#####################reason of unhandle err', reason);
  });
  process.nextTick(() => {
    console.log('second#####################nextTick in setImmediate');
  });
});

new Promise((resolve) => {
  console.log('second#####################independent promise');
  resolve('second##########################pomise then data');
}).then(() => {
  console.log('second#####################then of the independent promise');
}).catch((reason) => {
  console.log('second#####################reason of unhandle err', reason);
});

process.nextTick(() => {
  console.log('second#####################independent nextTick');
});
console.log('glabal');
